#include "connectorlist.h"
#include <QDebug>
QMap<QString,Connector*>* ConnectorList::clients;
std::mutex ConnectorList::m_mutex;

ConnectorList::ConnectorList()
{}

QMap<QString, Connector *> *ConnectorList::getClients()
{
    std::unique_lock<std::mutex> lock(m_mutex);
    if(clients == NULL)
    {
        clients = new QMap<QString,Connector*>;
        qDebug() << "init clients success";
    }
    return clients;
}

void ConnectorList::deleteClients()
{
    std::unique_lock<std::mutex> lock(m_mutex);
    if(clients == NULL)
    {
        delete clients;
        clients = NULL;
    }
}

void ConnectorList::deleteClient(QString name)
{
    Connector* c = clients->take(name);
    delete c;
    clients->remove(name);
}
